package csc.daonjpa.java.dao;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;

import csc.daonjpa.java.domain.Customer;
import csc.daonjpa.java.transaction.TransactionManager;

public class CustomerDAO {
	public List<Customer> getCustomer() {
		EntityManager em = TransactionManager.getEntityManager();
		TypedQuery<Customer> query = em.createQuery("SELECT a FROM Customer a", Customer.class);
		List<Customer> customers = null;
		customers = query.getResultList();
		
		return customers;
	}
	
	public boolean addCustomer(Customer customer) {
		EntityManager em = TransactionManager.getEntityManager();
		em.persist(customer);
		return true;
	}
}
